package com.huawei.boss.statemachine;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.util.Log;

public class State {
    private Map<String, Action> actions = new HashMap<String, Action>();
    private Enum name;
    private Action enter;
    private Action exit;

    public State(Enum name) {
        this.name = name;
    }

    public Object getName() {
        return this.name;
    }

    public void enter() {
        if (this.enter != null) {
            this.enter.call();
        }
    }

    public void enter(Action enter) {
        this.enter = enter;
    }

    public void exit() {
        if (this.exit != null) {
            this.exit.call();
        }
    }

    public void exit(Action exit) {
        this.exit = exit;
    }

    public void addAction(String name, Action action) {
        actions.put(name, action);
    }

    public void fireAction(String actionName, Object... params) {
        if (actions.containsKey(actionName)) {
            Action action = actions.get(actionName);
            action.call(params);
        }
    }
}